<template>
    <!-- 绑定属性 -->
    <section class="toast-container" :class="[visible?'fade-in':'fade-out']">
        <div class="toast">
            <span>{{message}}</span>
        </div>
    </section>
</template>
<script>
export default {
    name:'vue-toast',
    data(){
        return{
            message:'',
            visible:false,
        }
    }
}
</script>
<style scoped>
    @keyframes fade-in {
        0%{
            opacity: 0;
            transform: scale(0.5)
        }
        100%{
            opacity: 1;
            transform: scale(1)
        }
    }
    @keyframes fade-out {
        0%{
            opacity: 1;
            transform: scale(1)
        }
        100%{
            opacity: 0;
            transform: scale(0.5)
        }
    }
    .toast-container{
        position: absolute;
        left: 0;
        top:0;
        right:0;
        z-index:2000;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .toast{
        width:180px;
        height: 60px;
        line-height: 60px;
        text-align: center;
        background-color: rgba(0,0,0,0.61);
        border-radius: 10px;
    }
    .fade-in{
        animation-name: fade-in;
        animation-duration: 0.3s;
        animation-fill-mode: both;
    }
    .fade-out{
        animation-name: fade-out;
        animation-duration: 0.3s;
        animation-fill-mode: both;
    }
</style>